package com.neusoft.news.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.neusoft.news.bean.Column;
import com.neusoft.news.utils.JDBCUtils;

public class ColumnDao {

	/**
	 * 查询全部栏目
	 * @return	栏目List
	 */
	public List<Column> selectAllColumn(){
		List<Column> columnlist = new ArrayList<Column>();
		try {
			String sql = "select * from \"d_column\"";
			PreparedStatement pst = JDBCUtils.getConnection().prepareStatement(sql);
			ResultSet rs = pst.executeQuery();
			while(rs.next()){
				Column column = new Column(
						rs.getString(1),rs.getString(2)
						);
				columnlist.add(column);
			}
//			rs.close();
//			pst.close();
//			JDBCUtils.destroy();
		} catch (SQLException | ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return columnlist;
	}
}
